package cn.tworice.client.web;

import cn.tworice.admin.service.PostsService;
import cn.tworice.common.entity.dto.PostsDto;
import com.lmk.core.web.support.api.RequestResult;
import com.lmk.core.web.support.api.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 企业发布的招聘职位信息
 * @Author 二饭
 * @Email 1786705138@qq.com
 * @Date 2021/12/13 21:08
 */
@RestController
@RequestMapping("client/recruit")
@CrossOrigin
public class RecruitClient {

    @Autowired
    private PostsService postsService;

    /**
     * 通过企业ID查询该企业发布的职位信息
     * @Author 二饭
     * @Email 1786705138@qq.com
     * @Date 2021/12/13 21:37
     */
    @GetMapping("{id}")
    public RequestResult postsList(@PathVariable("id") String id,Integer pageSize,Integer page) {
        RequestResult result = new RequestResult();
        List<PostsDto> list = postsService.getListByCompanies(id,pageSize,page);
        result.appendData("list", list);
        return result;
    }

    /**
     * 提交表单
     * @Author 二饭
     * @Email 1786705138@qq.com
     * @Date 2021/12/14 13:26
     */
    @PostMapping("")
    public RequestResult edit(PostsDto postsDto){
        RequestResult result = new RequestResult();
        postsService.setPosts(postsDto);
        result.setCode(new StatusCode(200,"更新成功"));
        return result;
    }

    /**
     * 删除职位信息
     * @Author 二饭
     * @Email 1786705138@qq.com
     * @Date 2021/12/14 13:26
     */
    @DeleteMapping("{id}")
    public RequestResult del(@PathVariable("id") String id){
        RequestResult result = new RequestResult();
        postsService.del(id);
        result.setCode(new StatusCode(200,"删除成功"));
        return result;
    }
    
}
